﻿#ifndef UDPINTERFACE_H
#define UDPINTERFACE_H

#include <QUdpSocket>
#include <QTimer>
#include <QThread>


namespace Hydra_UDP
{

#define DEFAULT_INTERVAL (200)                                  // 默认通信周期200ms

#define CAB_A_J_COMID (0x0439)
#define CAB_A_R_COMID (0x043A)
#define CAB_B_J_COMID (0x0565)
#define CAB_B_R_COMID (0x0566)

typedef enum _cab{
    NONE,
    A,
    B
}CAB;


typedef enum _network{
    INIT,
    J,
    R
}NETWORK;


#pragma pack(push, 1)                   // 将以下结构体设置内存对齐为1个字节


// 数据包头信息采用众志诚私有协议的Process_Data的接收数据帧
typedef struct _send_header {
    quint8 start_byte = 0xFE;                                   // 起始字节
    quint8 eth_id = 0x07;                                       // 命令字，J网:0x07, R网:0x87
    quint8 msg_len_hight = 0x00;                                // 数据长度高位
    quint8 msg_len_low = 0x6d;                                  // 数据长度低位
    quint32 sequence_counter = 0x00000000;                      // 序列号计数器
    quint16 protocol_version = 0x0100;                          // 协议版本
    quint32 com_id = 0x00000000;                                // ComId
    quint32 etb_to_po_cnt = 0x00000000;                         // 列车静态拓扑序列
    quint32 op_trn_to_po_cnt = 0x00000000;                      // 列车动态拓扑序列
    quint32 data_length = 0x00000057;                           // 应用数据长度
}SEND_HEADER;

// 接收数据包头信息采用众志诚私有协议的发送对应ComID的数据
typedef struct _received_header {
    quint8 start_byte = 0xFE;                                   // 起始字节
    quint8 eth_id = 0x53;                                       // 命令字，J网:0x53, R网:0xd3
    quint8 msg_len_hight;                                       // 数据长度高位
    quint8 msg_len_low;                                         // 数据长度低位
    quint32 source_ip = 0x00000000;                             // 源ip地址
    quint32 multicast_id = 0x00000000;                          // 组播地址
    quint32 com_id;                                             // Com_Id
    quint32 data_length;                                        // 应用数据长度
}RECEIVED_HEADER;


typedef struct _received_msg {
    quint8 msg_type;                                            // 消息类型
    quint32 sequence;                                           // 序列号
    quint16 reserved_1;                                         // 预留
    quint8 control_state;                                       // 控车状态，bit0 = 1 TC1端OBC控车，bit1 = 1 TC1端OBC健康，bit2 = 1 TC2端OBC控车，bit3 = 1 TC2端OBC健康
    quint8 cur_mode;                                            // 当前列车模式，0: 模式未知，1: RM， 2: CM, 3: AM, 4: FAM，5:EUM, 6:CAM
    quint8 available_mode;                                      // 可用模式, bit0 = 1 CM可用， bit1 = 1 AM可用， bit2 = 1 FAM可用, bit3 = 1 CAM可用
    qint32 train_speed;                                         // 列车速度，单位km/h，负值表示退行
    quint8 direction;                                           // 列车运行方向, 0: 无效， 0x5A: 上行， 0xA5: 下行
    quint32 author_speed;                                       // 授权速度，单位:0.1km/h
    quint32 FSB_speed;                                          // FSB速度, 单位:0.1km/h
    quint32 recommendation_speed;                               // 推荐速度, 单位:0.1km/h
    quint32 target_distance;                                    // 目标距离, 单位:mm
    quint32 target_speed;                                       // 目标限制速度, 单位:mm/s
    quint8 PSD_state;                                           // 屏蔽门状态, 0: 无效, 1: 关闭, 2: 打开
    quint8 EB_state;                                            // EB状态， 0: 无EB， 1: EB
    quint8 FSB_state;                                           // FSB状态, 0: 无FSB， 1: FSB中, 2: FSB可缓解
    quint8 location_flag;                                       // 列车位置标志，0: 未定位， 1: 在车辆段/停车场， 2: 在转换轨， 3: 在正线
    quint8 TACS_control_mode;                                   // TACS控车模式，0:未知， 1:中控， 2:车控
    quint8 request_train_control;                               // 请求车控， 1:请求车控
    quint16 reserved_2;                                         // 预留
    quint32 reserved_3;                                         // 预留
    quint8 wheel_calibration;                                   // 轮径校准, 0:未效准，1:已校准
    quint8 align;                                               // 站台对准，0:未对准，1:已对准
    quint8 pre_selected_mode;                                   // 预选模式， 0:模式未知，1:RM， 2:CM, 3:AM, 4:FAM
    quint32 reserved_4;                                         // 预留
    quint8 routine_inspection_confirm;                          // 例检确认，0:不在例检，1:确认进入例检
    quint8 communication_state;                                 // 车地通信状态，0:J/R网均丢失，1:R网丢失，2：J网丢失，3:J/R通信均正常
    quint32 reserved_5;                                         // 预留
    quint32 cur_station;                                        // 当前站ID
    quint32 next_station;                                       // 下一站ID
    quint32 destination;                                        // 终点站ID
    qint32 stop_dist;                                           // 停车距离
    quint32 next_station_dist;                                  // 下一站距离
    quint32 dwell_time;                                         // 停站倒计时
    quint8 door_mode;                                           // 门控模式，0: 无， 1: 自动开自动关， 2: 自动开手动关， 3: 手动开手动关
    quint8 depature;                                            // 发车提示, 0: 无效, 1: 发车, 2: 提前发车
    quint8 turn_back;                                           // 折返状态, 0: 未折返， 1: 正在自动折返， 2: 可自动折返
    quint8 motoring_state;                                      // 牵引状态, 0: 无效, 1: 牵引, 2: 惰行, 3: 制动
    quint8 active_cab;                                          // 激活车头，0:未知，1:TC1端，2:TC2端
    quint8 door_side_a_state;                                   // A侧车门状态，0:未知，1:开，2:关
    quint8 door_side_b_state;                                   // B侧车门状态，0:未知，1:开，2:关
    quint8 routine_inspection_prompt;                           // 例检提示
    quint8 alarm_reason1;                                       // 报警原因1，bit0=1：动车时方向手柄变化，bit1=1:位置丢失，bit3:当前驾驶模式不可用
    quint8 alarm_reason2;                                       // 报警原因2，bit3=1:连续式列车冒进红灯
    quint8 alarm_reason3;                                       // 报警原因3，bit3=1:单轮打滑，bit4=1:双轮打滑，bit6=1:FAM模式因司机使钥匙激活正常退出
    quint8 alarm_reason4;                                       // 报警原因4
    quint8 alarm_reason5;                                       // 报警原因5，bit1=1:列车超速，bit2=1:倒溜超限，bit3=1:未授权回退，bit4=1:列车牵引受阻，bit5=1:非期望移动，bit6=1:车门未关闭时移动，bit7=1:空转打滑
    quint8 alarm_reason6;                                       // 报警原因6，bit4=1:超速报警1，bit5=1:超速报警2，bit7=1:回退可用
    quint8 alarm_reason7;                                       // 报警原因7，bit0=1:退行超限，bit1=1:回退激活，bit2=1:丢失应答器，bit3=1:非预期应答器，bit4=1:位置不确定性超限
    quint8 alarm_reason8;                                       // 报警原因8，bit7=1:模式选择无效
    quint8 alarm_reason9;                                       // 报警原因9，bit6=1:非法RUN按钮输入
    quint8 alarm_reason10;                                      // 报警原因10，bit0=1:非法的客室门开/关门按钮输入
    quint8 alarm_reason11;                                      // 报警原因11，bit0=1:列车完整性丢失
    quint8 alarm_reason12;                                      // 报警原因12，bit3=1:轮径超标，bit4=1:轮径超限，bit5=1:轮径校准失败次数超限，bit6=1:轮径偏差超限
    quint8 alarm_reason13;                                      // 报警原因13
    quint8 alarm_reason14;                                      // 报警原因14，bit0=1:列车停站超时，bit1=1:扣车命令被拒绝，bit2=1:停站时间命令无效，bit3=1:跳停命令被拒绝
    quint8 alarm_reason15;                                      // 报警原因15
    quint8 alarm_reason16;                                      // 报警原因16
    quint8 alarm_reason17;                                      // 报警原因17，bit2=1:列车EB
    quint8 alarm_reason18;                                      // 报警原因18，bit7=1:列车开门失败
    quint8 alarm_reason19;                                      // 报警原因19，bit0=1:列车关门失败，bit2=1:列车对站失败，bit6=1:站台门旁路激活，bit7=1:站台门旁路取消
    quint8 alarm_reason20;                                      // 报警原因20，bit0=1:连续丢失2个应答器，bit1=0:非法应答器信号，bit2=1:唤醒列车位置校验失败，bit3=1:建立定位失败
    quint8 alarm_reason21;                                      // 报警原因21
    quint8 alarm_reason22;                                      // 报警原因22
    quint8 alarm_reason23;                                      // 报警原因23
    quint8 alarm_reason24;                                      // 报警原因24
    quint8 alarm_reason25;                                      // 报警原因25，bit1=1:方向手柄0位时列车移动，bit5=1:可通过拔出钥匙进入FAM，bit7=1:ATO短距离发车失败
    quint8 alarm_reason26;                                      // 报警原因26
    quint8 alarm_reason27;                                      // 报警原因27
    quint8 alarm_reason28;                                      // 报警原因28
    quint8 alarm_reason29;                                      // 报警原因29
    quint8 alarm_reason30;                                      // 报警原因30，bit3=1:制动重故障，bit4=1:门使能状态和门使能命令输出不一致，bit7=1:人工洗车按钮按下
    quint8 alarm_reason31;                                      // 报警原因31，bit6=1:紧急手柄拉下无效，bit7=1:运营等级命令无效
    quint8 alarm_reason32;                                      // 报警原因32，bit1=1:干湿轨命令无效
    quint32 reserved_6;                                         // 报警预留
    quint32 reserved_7;                                         // 预留预留
    quint16 reserved_8;                                         // 预留
    quint8 CRC;                                                 // CRC校验
    quint32 reserved_9;                                        // 预留
    quint32 reserved_10;                                        // 预留
    quint32 reserved_11;                                        // 预留
    quint32 reserved_12;                                        // 预留
}RECEIVED_MSG ;




typedef struct _send_msg {
    quint8 msg_type = 0x73;                                     // 消息类型
    quint32 sequence = 0x00000000;                              // 序列号
    quint16 PVID = 0x0000;                                      // PVID,列车号
    quint8 cur_display_mode = 0x00;                             // 当前显示模式, 0:模式未知, 1:RM, 2:CM, 3:AM, 4:FAM, 5:CAM
    quint8 inhibit_door_auto = 0x00;                            // 禁止自动开门，bit0 = 1 有效， bit0 = 0 无效
    quint8 train_control_response = 0x00;                       // 车控选择反馈，1 确认选择车控
    quint8 reserved_1 = 0x00;                                   // 预留
    quint8 mode_selected = 0x00;                                // 预选模式选择, 1s脉冲, 0:无请求， 1:RM, 2:CM, 3:AM, 4:FAM,
    quint8 info_group = 0x00;                                   // bit0, 预留， bit1: 自动折返按钮， bit2: 轮径设置有效(2s脉冲)
    quint16 TC1_bogie1_axle1_wheel_diameter = 0x0000;           // TC1端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 TC1_bogie1_axle2_wheel_diameter = 0x0000;           // TC1端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 TC1_bogie2_axle1_wheel_diameter = 0x0000;           // TC1端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 TC1_bogie2_axle2_wheel_diameter = 0x0000;           // TC1端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 M1_bogie1_axle1_wheel_diameter = 0x0000;            // M1端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 M1_bogie1_axle2_wheel_diameter = 0x0000;            // M1端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 M1_bogie2_axle1_wheel_diameter = 0x0000;            // M1端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 M1_bogie2_axle2_wheel_diameter = 0x0000;            // M1端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 M2_bogie1_axle1_wheel_diameter = 0x0000;            // M2端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 M2_bogie1_axle2_wheel_diameter = 0x0000;            // M2端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 M2_bogie2_axle1_wheel_diameter = 0x0000;            // M2端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 M2_bogie2_axle2_wheel_diameter = 0x0000;            // M2端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 M3_bogie1_axle1_wheel_diameter = 0x0000;            // M3端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 M3_bogie1_axle2_wheel_diameter = 0x0000;            // M3端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 M3_bogie2_axle1_wheel_diameter = 0x0000;            // M3端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 M3_bogie2_axle2_wheel_diameter = 0x0000;            // M3端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 M4_bogie1_axle1_wheel_diameter = 0x0000;            // M4端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 M4_bogie1_axle2_wheel_diameter = 0x0000;            // M4端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 M4_bogie2_axle1_wheel_diameter = 0x0000;            // M4端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 M4_bogie2_axle2_wheel_diameter = 0x0000;            // M4端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 TC2_bogie1_axle1_wheel_diameter = 0x0000;           // TC2端1架1轴轮径，单位:mm, 有效范围770-840
    quint16 TC2_bogie1_axle2_wheel_diameter = 0x0000;           // TC2端1架2轴轮径，单位:mm, 有效范围770-840
    quint16 TC2_bogie2_axle1_wheel_diameter = 0x0000;           // TC2端2架1轴轮径，单位:mm, 有效范围770-840
    quint16 TC2_bogie2_axle2_wheel_diameter = 0x0000;           // TC2端2架2轴轮径，单位:mm, 有效范围770-840
    quint16 driver_id = 0x0000;                                 // 司机号
    quint8 into_routine_inspection = 0x00;                      // 请求进入例检
    quint8 eb_request = 0x00;                                   // EB请求
    quint8 eb_release_request = 0x00;                           // EB缓解请求
    quint8 creep_request = 0x00;                                // 蠕动请求
    quint8 creep_cancel_request = 0x00;                         // 蠕动取消请求
    quint8 broadcast_request = 0x00;                            // 广播请求
    quint8 quit_routine_inspection = 0x00;                      // 退出例检
    quint8 CRC = 0x00;                                          // CRC校验
}SEND_MSG ;

#pragma pack(pop)                       // 结束内存对齐设置

typedef struct _device{
    QString device_name;
    QString ip_J;
    quint16 port_J;
    QString ip_R;
    quint16 port_R;
}DEVICE;



static const quint8 crc8_table[] =
{
    0x00,0x31,0x62,0x53,0xc4,0xf5,0xa6,0x97,0xb9,0x88,0xdb,0xea,0x7d,0x4c,0x1f,0x2e,
    0x43,0x72,0x21,0x10,0x87,0xb6,0xe5,0xd4,0xfa,0xcb,0x98,0xa9,0x3e,0x0f,0x5c,0x6d,
    0x86,0xb7,0xe4,0xd5,0x42,0x73,0x20,0x11,0x3f,0x0e,0x5d,0x6c,0xfb,0xca,0x99,0xa8,
    0xc5,0xf4,0xa7,0x96,0x01,0x30,0x63,0x52,0x7c,0x4d,0x1e,0x2f,0xb8,0x89,0xda,0xeb,
    0x3d,0x0c,0x5f,0x6e,0xf9,0xc8,0x9b,0xaa,0x84,0xb5,0xe6,0xd7,0x40,0x71,0x22,0x13,
    0x7e,0x4f,0x1c,0x2d,0xba,0x8b,0xd8,0xe9,0xc7,0xf6,0xa5,0x94,0x03,0x32,0x61,0x50,
    0xbb,0x8a,0xd9,0xe8,0x7f,0x4e,0x1d,0x2c,0x02,0x33,0x60,0x51,0xc6,0xf7,0xa4,0x95,
    0xf8,0xc9,0x9a,0xab,0x3c,0x0d,0x5e,0x6f,0x41,0x70,0x23,0x12,0x85,0xb4,0xe7,0xd6,
    0x7a,0x4b,0x18,0x29,0xbe,0x8f,0xdc,0xed,0xc3,0xf2,0xa1,0x90,0x07,0x36,0x65,0x54,
    0x39,0x08,0x5b,0x6a,0xfd,0xcc,0x9f,0xae,0x80,0xb1,0xe2,0xd3,0x44,0x75,0x26,0x17,
    0xfc,0xcd,0x9e,0xaf,0x38,0x09,0x5a,0x6b,0x45,0x74,0x27,0x16,0x81,0xb0,0xe3,0xd2,
    0xbf,0x8e,0xdd,0xec,0x7b,0x4a,0x19,0x28,0x06,0x37,0x64,0x55,0xc2,0xf3,0xa0,0x91,
    0x47,0x76,0x25,0x14,0x83,0xb2,0xe1,0xd0,0xfe,0xcf,0x9c,0xad,0x3a,0x0b,0x58,0x69,
    0x04,0x35,0x66,0x57,0xc0,0xf1,0xa2,0x93,0xbd,0x8c,0xdf,0xee,0x79,0x48,0x1b,0x2a,
    0xc1,0xf0,0xa3,0x92,0x05,0x34,0x67,0x56,0x78,0x49,0x1a,0x2b,0xbc,0x8d,0xde,0xef,
    0x82,0xb3,0xe0,0xd1,0x46,0x77,0x24,0x15,0x3b,0x0a,0x59,0x68,0xff,0xce,0x9d,0xac
};

const quint16 crc16_table[] =
{
    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
    0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
    0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
    0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
    0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
    0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
    0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
    0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
    0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
    0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
    0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
    0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
    0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
    0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
    0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
    0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
    0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
    0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
    0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
    0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
    0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
    0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
    0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
    0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
    0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
    0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
     0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
    0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
    0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
    0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
    0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
    0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};


}


using namespace Hydra_UDP;


class UdpInterface : public QObject
{
    Q_OBJECT
public:
    explicit UdpInterface(QObject *parent = nullptr);
    UdpInterface(QString path/*, QSocketDescriptor sock*/);
    void bindNet(NETWORK net);
    void setCommunicationCycle(quint16 value);                                          // 设置通信周期
    bool getConnectState();                                                             // 获取网络连接状态
    void setMainNet(bool value);                                                        // 设为主用网络
    CAB getCab();                                                                       // 获取激活车头
    void setPreMode(quint8 value);                                                      // 设置预选模式



private:
    void init(QString path);
    void readConfigFile(QString path);
    quint8 calCRC8(QByteArray bytes, quint8 poly);                                      // 根据多项式计算CRC8
    quint8 calCRC8FromCRC8Table(QByteArray bytes);                                      // 通过查表计算CRC8
    quint16 calCRC16FromCRC16Table(unsigned char *buf, int len = 0);                    // 通过传入指针的形式，查表计算CRC16
    quint16 calCRC16FromCRC16Table(QByteArray byte);                                    // 通过传入字节数组的形式，查表计算CRC16
    void addTRDPHeader(QByteArray* pByte);                                              // 添加TRDP报文头
    void addSendMsgData(QByteArray* pByte);                                             // 添加发送数据
    void addTRDPCRC16(QByteArray* pByte);                                               // 添加TRDP协议CRC16

public slots:
    void processReceivedMsg();
    void sendMsgToATP();                                                                // 发送数据给ATP


signals:
    void sendReceivedData(QByteArray data);
    void killConnectTimer();
    void request();


private:
    QUdpSocket* pSocket;
    QTimer mTimer;
    bool receivedMsgFlag = true;
    DEVICE mHmi;
    DEVICE mLocalAtp;
    DEVICE mRemoteAtp;
    CAB mCab = CAB::NONE;                                                               // 默认在A端
    NETWORK mNet = NETWORK::INIT;                                                       // 默认J网
    bool mMainNet = false;                                                              // 主用网络
    quint32 mSendSequence = 0;                                                          // 发送序列号
    bool mConnectState = false;                                                         // 网络链接状态
    QTimer mConnectTimer;
    quint8 mPreMode = 0x01;
};

#endif // UDPINTERFACE_H
